package 力扣;

public class  leetcode977 {
    public static void main(String[] args) {
        sortedSquares(new int[]{-7,-3,2,3,11});
    }
    public static int[] sortedSquares(int[] nums) {
        int leftPoint=0;
        int rightPoint=nums.length-1;
        int[] ints=new int[nums.length];
        int count=nums.length-1;
        while (true){
            if(Math.abs(nums[leftPoint])>Math.abs(nums[rightPoint])){
                ints[count]=nums[leftPoint]*nums[leftPoint];
                leftPoint++;
                count--;
            }else {
                ints[count]=nums[rightPoint]*nums[rightPoint];
                rightPoint--;
                count--;
            }
            if(count==-1) break;
        }
        return ints;
    }
}
